﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using StripeDemo.Utils;
using StripeNET;
namespace StripeDemo.Controllers
{
    public class ReportController : Controller
    {
        //
        // GET: /Report/
        public ActionResult Index()
        {
            ViewBag.Msg = "Obtain client payment method";
            return View();
        }

        public ActionResult Detail()
        {
            StripeCustomer customer = null;
            if (HttpContext.Request.RequestType == "POST")
            {
                string customerID = Request.Form[Constant.CUSTOMER_ID].ToString();
                customer = Util.getUserInfoById(customerID);
                if (null == customer)
                {
                    ViewBag.Msg = "Customer ID not exist!";
                    return View("Index");
                }
                var chargeService = new StripeChargeService();
                StripeChargeListOptions stripeChargeListOption = new StripeChargeListOptions();
                stripeChargeListOption.CustomerId = customerID;
                IEnumerable<StripeCharge> listCharge = chargeService.List(stripeChargeListOption);
                ViewBag.StripeCharge = listCharge.ToList();
            }
            return View(customer);
        }
    }
}